import tensorflow as tf
import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_csv('../data/Income.csv')
print(data)

# 绘制散点图
plt.scatter(data.Education, data.Income)
plt.legend()
plt.show()

x = data.Education
y = data.Income

model = tf.keras.Sequential()
model.add(tf.keras.layers.Dense(1, input_shape=(1,)))
model.summary()

model.compile(optimizer="adam", loss="mse")

history = model.fit(x, y, epochs=5000)

# 预测
print(model.predict(x))
print(model.predict(pd.Series(20)))
print(model.predict(pd.Series([20, 30])))
